﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace BackOfficeAssistance
{
    public class Tester
    {
        public void LinqTest()
        {
            List<TmpData> x = new List<TmpData>(){
                new TmpData() {a="1",b="2",c="3",d=4,e=new DateTime( 2013,11,04) },
                new TmpData() {a="11",b="22",c="33",d=44,e=new DateTime( 2013,11,05) },
                new TmpData() {a="111",b="222",c="333",d=444,e=new DateTime( 2013,11,06) }
            };

            var test = from y in x
                       where y.d >= 44
                       select y;
            foreach (var t in test)
                MessageBox.Show(t.a + t.b + t.c + (t.d).ToString());
        }

        /* the ScriptManager !!!
         * ScriptManager.RegisterStartupScript(Page, Page.GetType(), "popup", "window.open('" + strUrl + "','_blank')", true);
        public static void Redirect(this HttpResponse response, string url, string target, string windowFeatures)
        {

            if ((String.IsNullOrEmpty(target) || target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && String.IsNullOrEmpty(windowFeatures))
            {
                response.Redirect(url);
            }
            else
            {
                Page page = (Page)HttpContext.Current.Handler;

                if (page == null)
                {
                    throw new InvalidOperationException("Cannot redirect to new window outside Page context.");
                }
                url = page.ResolveClientUrl(url);

                string script;
                if (!String.IsNullOrEmpty(windowFeatures))
                {
                    script = @"window.open(""{0}"", ""{1}"", ""{2}"");";
                }
                else
                {
                    script = @"window.open(""{0}"", ""{1}"");";
                }
                script = String.Format(script, url, target, windowFeatures);
                ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);
            }
        }*/
    }

    public class TmpData
    {
        public string a { get; set; }
        public string b { get; set; }
        public string c { get; set; }
        public int d { get; set; }
        public DateTime e { get; set; }
    }
}
